package com.qingcheng.consumer;

import com.alibaba.dubbo.config.annotation.Reference;
import com.qingcheng.pojo.goods.Sku;
import com.qingcheng.service.goods.SkuService;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.core.MessageListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.io.UnsupportedEncodingException;

/**
 * 删除ElasticSearch索引
 */

public class ElasticSearchIndexDeleteConsumer implements MessageListener {

    @Autowired
    private IndexUtil indexUtil;

    @Override
    public void onMessage(Message message) {
        try {
            //获取传来的mapJsonString数据
            String mapJsonString = new String(message.getBody(),"UTF-8");
            System.out.println("删除ElasticSearch索引");
            indexUtil.deleteIndex(mapJsonString);
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
    }
}
